package com.zhihesj.anan.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhihesj.anan.system.entity.Role;
import com.zhihesj.anan.system.entity.User;
import com.zhihesj.anan.system.mapper.UserMapper;
import com.zhihesj.anan.system.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author anan
 * @since 2020-04-20
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Role> getRolesByUsername(String username) {
        return userMapper.getRolesByUsername(username);
    }

    @Override
    public List<User> getUserByUsername(String username) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("username", username);
        return userMapper.selectList(wrapper);
    }

    @Override
    public List<Role> getRolesById(Long id) {
        return userMapper.getRolesById(id);
    }

    @Override
    public List<Role> getRolesByIdentifier(String identifier) {
        return userMapper.getRolesByIdentifier(identifier);
    }

}
